package sliver.action.shop;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import sliver.entity.Category;
import sliver.service.ShopManager;

import com.opensymphony.xwork2.ActionSupport;

@Scope("prototype")
@Controller("shop.deleteCategoryAction")
public class DeleteCategoryAction extends ActionSupport{

	private static final long serialVersionUID = -6466522436270830728L;
	
	private Long categoryId;
	
	@Autowired
	private ShopManager shopManager;
	
	public DeleteCategoryAction(){
		
	}

	public Long getCategoryId() {
		return categoryId;
	}

	public void setCategoryId(Long categoryId) {
		this.categoryId = categoryId;
	}

	@Override
	public String execute() throws Exception {
		Category category = shopManager.removeCategory(categoryId);
		if(category != null)
			return SUCCESS;
		
		return ERROR;
	}
}
